<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class AuthService extends CI_Controller
{

	//Doctrine EntityManager
	public $em;

	function __construct()
	{
 		parent::__construct();

  		//Not required if you autoload the library
 		$this->load->library('doctrine');

  		//Instantiate a Doctrine Entity Manager
 		$this->em = $this->doctrine->em;
 	}
	
	public function index()
	{
		die("index");
		$user = new models\User;
		$user->setUsername('Joseph');
		$user->setPassword('Password');		
		$this->em->persist($user);
		$this->em->flush(); 
	}
	
	public function login(){		
		if (models\service\CurrentUser::login($this->input->post('username'), $this->input->post('password')) == FALSE){
			echo ">>" . models\service\CurrentUser::getErrorMessage();
		} else {
			header('location: '.base_url().'katalog');		
		}		
	}	
	
}